{% extends 'base.html' %}

{% block title %}{{ notification.title }} - {{ block.super }}{% endblock %}

{% block content %}
<div class="row">
    <div class="col-md-8 offset-md-2">
        <div class="card">
            <div class="card-header d-flex justify-content-between align-items-center">
                <h4 class="mb-0">{{ notification.title }}</h4>
                <div>
                    <a href="{% url 'core:notification_list' %}" class="btn btn-sm btn-outline-secondary me-2">返回列表</a>
                    <button type="button" class="btn btn-sm btn-danger" data-bs-toggle="modal" data-bs-target="#deleteModal">
                        删除通知
                    </button>
                </div>
            </div>
            <div class="card-body">
                <div class="mb-3">
                    <small class="text-muted">发送者: {{ notification.sender.username }}</small>
                    <span class="mx-2">|</span>
                    <small class="text-muted">发送时间: {{ notification.created_at|date:"Y-m-d H:i:s" }}</small>
                    {% if notification.task %}
                    <div class="mt-2">
                        <span class="badge bg-success">关联待办</span>
                        <a href="{% url 'core:class_task_todo_detail' notification.task.id %}" class="text-success ms-1">{{ notification.task.title }}</a>
                    </div>
                    {% endif %}
                </div>
                <hr>
                <div class="notification-content">
                    {{ notification.content|linebreaks }}
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 删除确认模态框 -->
<div class="modal fade" id="deleteModal" tabindex="-1" aria-labelledby="deleteModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="deleteModalLabel">确认删除</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                确定要删除通知 <strong>{{ notification.title }}</strong> 吗？此操作不可撤销。
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                <form action="{% url 'core:delete_notification' notification.id %}" method="post">
                    {% csrf_token %}
                    <button type="submit" class="btn btn-danger">确认删除</button>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %}